package com.plat.net.udp;


import com.plat.net.udp.code.MysqlDecoder;
import io.netty.channel.Channel;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.nio.NioDatagramChannel;

/**
 * 初始化管道处理器
 */
public class UDPChannelInitial extends AbstractChannel<NioDatagramChannel> {
    @Override
    protected void pipeline(Channel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //获取一个代理的channel
        Channel proxyChannel = getProxyChannel("127.0.0.1", 3306);
        pipeline.addLast("decoder", new MysqlDecoder());
        //tcp转发channel,从proxyChannel读取服务器返回的数据
        pipeline.addLast("serverHandler", new UDPDataSwapHandler(proxyChannel));
    }
}
